﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterCRM.master" AutoEventWireup="true" CodeFile="Reports.aspx.cs" Inherits="Reports" %>
<%@ MasterType VirtualPath="~/MasterCRM.master"%>

<%@ Register src="UC/SearchCritetia.ascx" tagname="SearchCritetia" tagprefix="uc" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
  <script language="javascript" type="text/javascript">
    function printReport(sender) {
      var siteDomainName = "<%=SiteDomainName%>";
      //alert(siteDomainName + '/DLRMonthlyStatementPrint.aspx');
      var popUpWindow = window.open('DLRMonthlyStatementPrint.aspx');
      popUpWindow.focus();
      popUpWindow.print();
      sender.visible = false;
      return false;
    }
  </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="body" Runat="Server">
  <div id="stylized" class="myform">
    <asp:DropDownList ID="ddlReportType" runat="server" AutoPostBack="true" onselectedindexchanged="ddlReportType_SelectedIndexChanged"></asp:DropDownList>
    <asp:Label ID="lblReportTypeReq" runat="server"  CssClass="error" >*</asp:Label>
          <asp:RequiredFieldValidator ID="reqReportType" runat="server" ControlToValidate="ddlReportType" InitialValue="0" SetFocusOnError="true" 
            CssClass="error" Text="Req" ErrorMessage="Req" ValidationGroup="submit" ></asp:RequiredFieldValidator>    
    <uc:SearchCritetia ID="ucscCallSC" runat="server"
      HideCallNo="true"
      HideACBrand="true"
      HideAcModelNo="true" 
      HideACPurchasedMonth="true"
      HideACSerialNo="true" 
      HideAddress="true"
      HideContactNo="true" 
      HideCustomerName="true"                  
      HideZipCode="true"
      HideCallLogDate="true"
      HideIsTempClosed="true"
      FetchMonthlyCashTransactionReport="true"      
      IsDealerRequired="true"
    />
    <asp:MultiView id="mvReports" runat="server" >
      <asp:View ID="vwDefaultView" runat="server">
        <div id="dvDefault" style=" height:380px;" >
          &nbsp;
        </div>
      </asp:View>
      <asp:View ID="vwDealerReport" runat="server">      
        <div id="mGrid">
          <asp:GridView ID="gvCashReport" runat="server" AutoGenerateColumns="false" OnRowDataBound="gvCashReport_RowDataBound">
            <Columns>
              <asp:TemplateField HeaderText="Call Status" ItemStyle-Width="60px">
                <ItemTemplate><asp:Label ID="lblStatusName" runat="server" Text='<%#Eval("CallStatus.StatusName")%>'></asp:Label></ItemTemplate>                
              </asp:TemplateField>
              <asp:BoundField DataField="Count" HeaderText="Count" ReadOnly="True" ItemStyle-Width="160px"
                SortExpression="ID">
                <ItemStyle Width="160px"></ItemStyle>
              </asp:BoundField>              
              <asp:BoundField DataField="DealerAcDR" HeaderText="Dealer DR" ReadOnly="True" ItemStyle-Width="160px"
              SortExpression="ID">
                <ItemStyle Width="160px"></ItemStyle>
              </asp:BoundField>
              <asp:BoundField DataField="DealerAcCR" HeaderText="Dealer CR" 
                ItemStyle-Width="60px">               
              </asp:BoundField>
              <asp:BoundField DataField="DealerDipositCR" HeaderText="Dealer CR" 
                ItemStyle-Width="60px">               
              </asp:BoundField>
            </Columns>
          </asp:GridView>

          <asp:GridView ID="gvDealerReport" runat="server" AutoGenerateColumns="False"
            GridLines="None" AllowPaging="true" Width="1210px" PageSize="25" CssClass="mGrid"
            AlternatingRowStyle-CssClass="alt" PagerStyle-CssClass="pgr" PagerSettings-Mode="NumericFirstLast"
            DataKeyNames="ID"  
            OnPageIndexChanging="gvDealerReport_PageIndexChanging">
            <AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>
            <Columns>
              <asp:BoundField DataField="ID" HeaderText="CallID" ReadOnly="True" ItemStyle-Width="120px"
                SortExpression="ID">                
              </asp:BoundField>
              <asp:BoundField DataField="CallReceiveDate" HeaderText="Date" DataFormatString="{0:dd/MMM/yy}"
                ItemStyle-Width="60px">               
              </asp:BoundField>
              <asp:TemplateField HeaderText="Call Type" ItemStyle-Width="60px">
                <ItemTemplate><%#Eval("CallType.CallTypeName")%></ItemTemplate>                
              </asp:TemplateField>
              <asp:TemplateField HeaderText="Dealer" ItemStyle-Width="120px">
                <ItemTemplate>
                  <%#Eval("Dealer.DealerName")%>
                </ItemTemplate>
                <ItemStyle Width="120px"></ItemStyle>
              </asp:TemplateField>
              <asp:TemplateField HeaderText="Customer" ItemStyle-Wrap="false" ItemStyle-Width="120px">
                <ItemTemplate>
                  <asp:Label ID="lnkCustomerName" runat="server" Text='<%#Eval("Customer.CustomerName")%>'></asp:Label>
                </ItemTemplate>            
              </asp:TemplateField>
               <asp:TemplateField HeaderText="Phone No" ItemStyle-Wrap="false" ItemStyle-Width="90px" >
                  <ItemTemplate>
                    <asp:Label ID="lblCustomerName" runat="server" Text='<%#Eval("Customer.MobileNo1")%>'></asp:Label>
                  </ItemTemplate>            
                </asp:TemplateField>
              <asp:TemplateField HeaderText="Brand" ItemStyle-Width="60px">
                <ItemTemplate>
                  <%#Eval("ACBrand.ACBrandName")%>
                </ItemTemplate>
                <ItemStyle Width="150px"></ItemStyle>
              </asp:TemplateField>              
              <asp:BoundField DataField="ACModelNo" HeaderText="Model" ItemStyle-Width="60px"></asp:BoundField>
              <asp:BoundField DataField="ACSerialNo" HeaderText="Sl No." ItemStyle-Width="60px"></asp:BoundField>
              <asp:BoundField DataField="ACPurchasedDate" HeaderText="Date Sold" ItemStyle-Width="60px" DataFormatString="{0:dd/MMM/yy}"></asp:BoundField>              
              <asp:TemplateField HeaderText="Status" ItemStyle-Width="60px">
                <ItemTemplate><%#Eval("CallStatus.StatusName")%></ItemTemplate>                
              </asp:TemplateField>              
              <asp:TemplateField HeaderText="Comment" ItemStyle-Width="50px">
                <ItemTemplate>
                  <asp:Label ID="lblComment" runat="server" Text="Comment" Style="cursor: pointer;
                    text-decoration: underline;"></asp:Label>
                  <asp:Panel ID="pnlPreviousComment" runat="server" Style="font-size: 11px; height: 50px;">
                    <%#Eval("Remarks")%>
                  </asp:Panel>
                  <ajaxToolkit:BalloonPopupExtender ID="popComment" runat="server" TargetControlID="lblComment"
                    BalloonPopupControlID="pnlPreviousComment" Position="BottomLeft" BalloonStyle="Rectangle"
                    BalloonSize="Large" UseShadow="false" DisplayOnClick="true" DisplayOnFocus="true" />
                </ItemTemplate>
                <ItemStyle Width="50px"></ItemStyle>
              </asp:TemplateField>
              <asp:BoundField DataField="IsTempClosed" HeaderText="Temp Closed" ItemStyle-Width="60px"></asp:BoundField>
              <asp:BoundField DataField="DealerAcDR" HeaderText="Debit" ItemStyle-Width="60px"></asp:BoundField>
              <asp:BoundField DataField="DealerAcCR" HeaderText="Credit" ItemStyle-Width="60px"></asp:BoundField>
            </Columns>
            <PagerSettings Mode="NumericFirstLast"></PagerSettings>
            <PagerStyle CssClass="pgr"></PagerStyle>
          </asp:GridView>
        </div>       
      </asp:View>          
    </asp:MultiView>
    <asp:Button ID="btnPrint" runat="server" Text="Print" Visible="false" OnClientClick="javascript:return printReport(this);" />  
  </div>   
</asp:Content>